<template>
	<view class="w-100">
		<view class="flex-1 mx-3">
			<view class="py-2 font-w font-s-4">提现信息</view>
			<view class="flex-1 row-ac py-2">
				<view class="latal-box text-muted font-s-45">收款人:</view>
				<view class="flex-1 border-bottom">
					<input type="text" class="p-2" value="" placeholder="收款人姓名" v-model="form.real_name" />
				</view>
			</view>
			<view class="flex-1 row-ac py-2">
				<view class="latal-box text-muted font-s-45">手机号:</view>
				<view class="flex-1 border-bottom">
					<input type="text" class="p-2" value="" placeholder="手机号" v-model="form.phone" />
				</view>
			</view>
			<view class="flex-1 row-ac py-2">
				<view class="latal-box text-muted font-s-45">支付宝账号</view>
				<view class="flex-1 border-bottom">
					<input type="text" class="p-2" value="" placeholder="支付宝账号" v-model="form.alipay_account" />
				</view>
			</view>
			<view class="flex-1 row-ac py-2">
				<view class="latal-box text-muted font-s-45">开户银行</view>
				<view class="flex-1 border-bottom">
					<input type="text" class="p-2" value="" placeholder="开户银行" v-model="form.bank_name" />
				</view>
			</view>
			<view class="flex-1 row-ac py-2">
				<view class="latal-box text-muted font-s-45">银行账户</view>
				<view class="flex-1 border-bottom">
					<input type="text" class="p-2" value="" placeholder="银行账户" v-model="form.bank_account" />
				</view>
			</view>
			<view class="flex-1 row mt-5">
				<view class="patch-box row" @click="patchWithdrawal">修 改</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		distributorsDetailUrl,
		distributionPatchUrl,
	} from '@/api/promotion';
	import {
		userInfoUrl,
		withdrawalDetailUrl,
		withdrawalPatchUrl
	} from '@/api/index.js'
	export default {
		data() {
			return {
				form: {
					id: '',
					real_name: '',
					phone: '',
					alipay_account: '',
					bank_name: '',
					bank_account: ''
				},
				disInfo: ''
			}
		},
		mounted() {
			this.token = uni.getStorageSync('token')
			if (this.token != '') {
				this.getUserInfo()
				this.getWithdrawalDetail()
			}
			
		},
		methods: {
			getUserInfo() {
				this.$R.get(userInfoUrl).then(res => {
					this.userInfo = res.data
				})
			},
			getWithdrawalDetail() {
				this.$R.get(withdrawalDetailUrl).then(res => {
					this.form = {
						id: res.data.id,
						phone: res.data.phone,
						real_name: res.data.real_name,
						alipay_account: res.data.alipay_account,
						bank_name: res.data.bank_name,
						bank_account: res.data.bank_account
					}
				})
			},
			patchWithdrawal() {
				this.$R.patch(withdrawalPatchUrl + this.form.id +'/', this.form).then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: '修改成功'
						});
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.latal-box {
		width: 182rpx;
	}

	.patch-box {
		width: 320rpx;
		height: 80rpx;
		background-color: #C95F0E;
		color: #fff;
		border-radius: 40rpx;
	}
</style>